COPY	START	0	COPY FILE FROM IN TO OUTPUT
	EXTDEF	BUFFER,BUFEND,LENGTH
	EXTREF	RDREC,WRREC
FIRST	STL	RETADR	SAVE RETURN ADDRESS
CLOOP	+JSUB	RDREC	READ INPUT RECORD
	LDA	LENGTH	TEST FOR EOF (LENGTH = 0)
	COMP	#0
	JEQ	ENDFIL	EXIT IF EOF FOUND
	+JSUB	WRREC	WRITE OUTPUT RECORD
	J	CLOOP	LOOP
ENDFIL	LDA	=C'EOF'	INSERT END OF FILE MARKER
	STA	BUFFER
	LDA	#3	SET LENGTH = 3
	STA	LENGTH
	+JSUB	WRREC	WRITE EOF
	J	@RETADR	RETURN TO CALLER
RETADR	RESW	1
LENGTH	RESW	1	LENGTH OF RECORD
	LTORG
BUFFER	RESB	4096	4096-BYTE BUFFER AREA
BUFEND	EQU	*
MAXLEN	EQU	BUFEND-BUFFER	MAXIMUM RECORD LENGTH
RDREC	CSECT
.
.	SUBROUTINE TO READ RECORD INTO BUFFER
.
	EXTREF	BUFFER,LENGTH,BUFEND
	CLEAR	X	CLEAR LOOP COUNTER
	CLEAR	A	CLEAR A TO ZERO
	CLEAR	S	CLEAR S TO ZERO
	LDT	MAXLEN
RLOOP	TD	INPUT	TEST INPUT DEVICE
	JEQ	RLOOP	LOOP UNTIL READY
	RD	INPUT	READ CHARACTER INTO REGISTER A
	COMPR	A,S	TEST FOR END OF RECORD (X'00')
	JEQ	EXIT	EXIT LOOP IF EOR
	+STCH	BUFFER,X	STORE CHARACTER IN BUFFER
	TIXR	T	LOOP UNLESS MAX LENGTH
	JLT	RLOOP	HAS BEEN REACHED
EXIT	+STX	LENGTH	SAVE RECORD LENGTH
	RSUB		RETURN TO CALLER
INPUT	BYTE	X'F1'	CODE FOR INPUT DEVICE
MAXLEN	WORD	BUFEND-BUFFER
WRREC	CSECT
.
.	SUBROUTINE TO WRITE RECORD FROM BUFFER
.
	EXTREF	LENGTH,BUFFER
	CLEAR	X	CLEAR LOOP COUNTER
	+LDT	LENGTH
WLOOP	TD	=X'05'	TEST OUTPUT DEVICE
	JEQ	WLOOP	LOOP UNTIL READY
	+LDCH	BUFFER,X	GET CHARACTER FROM BUFFER
	WD	=X'05'	WRITE CHARACTER
	TIXR	T	LOOP UNTIL ALL CHARACTERS
	JLT	WLOOP	HAVE BEEN WRITTEN
	RSUB		RETURN TO CALLER
	END	FIRST